package com.android.infantschool.model.mvp.presenter;

import com.android.infantschool.bean.BaseBean;
import com.android.infantschool.model.mvp.model.ApiModel;
import com.android.infantschool.model.mvp.model.ApiModelImpl;
import com.android.infantschool.model.mvp.model.OnApiListener;
import com.android.infantschool.model.mvp.view.ClockBaseView;

import java.util.Map;

/**
 * @author Administrator
 * @particulars
 * @time 2019\7\24 0024 8:54
 * @class describe
 */
public class ClockBasePresenterImpl implements ClockBasePresenter, OnApiListener {

    private ClockBaseView clockBaseView;
    private ApiModel apiModel;

    public ClockBasePresenterImpl(ClockBaseView clockBaseView) {
        this.clockBaseView = clockBaseView;
        this.apiModel = new ApiModelImpl();
    }

    @Override
    public void onDestroy() {
        clockBaseView = null;
    }

    @Override
    public void getClockBase(Map<String, String> map) {
        apiModel.getClockBase(this, map);
    }

    @Override
    public void onError(String error) {
        if (clockBaseView != null) {
            clockBaseView.errorClockBase(error);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (clockBaseView != null) {
            clockBaseView.successClockBase(baseBean);
        }
    }

}